<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   <meta http-equiv="Content-Type" content="text/html; charset=GBK">
   <title>WebService</title>
   <link href="${pageContext.request.contextPath}/layui/src/css/layui.css" rel="stylesheet" media="all">
   <style type="text/css">
   		.loginForm{margin-left: 40%}
   		.loginFormHeader{margin-left: 46%;margin-top: 5%}
   		.loginFormFoot{margin-left: 48%}
   		.layadmin-user-login-box .layadmin-user-login-header{margin-left: 20px}
   		.layui-input{width: 320px}
   		/* .layui-form-item .loginBtn{width: 300px} */
   </style>
  </head>
  
  <body>


  <div class="loginFormHeader">
      <h2>WebService</h2>
  </div>
  <form id="loginForm" class="loginForm">
    <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
      <div class="layui-form-item">
        <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
        <input type="text" name="username" id="username" lay-verify="required" placeholder="用户名" class="layui-input">
      </div>
      <div class="layui-form-item">
        <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
        <input type="password" name="password" id="password" lay-verify="required" placeholder="密码" class="layui-input">
      </div>
      <div class="layui-form-item" style="width:320px">
	      <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="loginForm">登 入</button>
	  </div>
    </div>
  </form>
  
  <div class="loginFormFoot">
    <p>© 2018 <a href="${pageContext.request.contextPath}/register.action" >注册</a></p>
  </div>
  
  
  </body>
  
<script src="${pageContext.request.contextPath}/layui/src/layui.js"></script>

<script type="text/javascript">
	layui.use([ 'form', 'jquery' ], function() {
		var $ = layui.jquery;
		var form = layui.form;
		layer.msg("欢迎");
		
		//监听提交
		form.on('submit(loginForm)', function(data){
		   console.log(JSON.stringify(data.field));
		   $("#loginForm").attr('action',"${pageContext.request.contextPath}/doLogin.action?username="+$("#username").val()+"&"+
				   "password="+$("#password").val()+"");    //通过jquery为action属性赋值
	       $("#loginForm").submit(); 
		   /* $.ajax({
			   url:'${pageContext.request.contextPath}/doLogin.action',
			   type:"post",
			   async:false,
			   data:{
				   "username":$("#username").val(),
				   "password":$("#password").val()
			   },
			   dataType:'json',
			   success:function(data){
				   console.log("日了狗");
			   }
		   })
		   return false; */
		});
		
	});
</script>
  
</html>
